package com.zhdl.modules.prefiresys.web.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.project.common.service.impl.BaseServiceImpl;
import com.project.network.entity.PortSocket;
import com.project.network.repository.PortSocketRepository;
import com.zhdl.modules.prefiresys.service.dto.BaseQueryCriteria;
import com.zhdl.modules.prefiresys.web.response.TcpSerialResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class PortTcpServiceImpl  extends BaseServiceImpl<String, PortSocket, PortSocketRepository> {

    public List<TcpSerialResp> getAllTcpList(){

        BaseQueryCriteria bc = new BaseQueryCriteria();

        List<PortSocket> list = findList(bc);

        List<TcpSerialResp> outData = new ArrayList<>();

        for (PortSocket item : list) {
            TcpSerialResp detRes = new TcpSerialResp();
            BeanUtil.copyProperties(item, detRes, CopyOptions.create().setIgnoreNullValue(true));
            detRes.setComType("tcp");
            outData.add(detRes);
        }
        return outData;
    }
}
